package com.weiaibenpao.demo.chislim;

import android.os.Parcel;
import android.os.Parcelable;

import com.amap.api.maps.model.LatLng;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ZJL on 2017/12/29.
 * 由两点组成的最短线段
 */

public class TwoPointLine implements Parcelable{
    private List<LatLng> latLngs;   //实际只有两个点，线段起点和终点
    private boolean isStartLine;    //是否是折线的起始线段（类似起始点概念）
    private boolean isDrawn;        //是否已绘制过

    public TwoPointLine() {
       this(false);
    }

    public TwoPointLine(boolean isStart) {
        this.isStartLine = isStart;
        this.latLngs = new ArrayList<>();
    }

    protected TwoPointLine(Parcel in) {
        latLngs = in.createTypedArrayList(LatLng.CREATOR);
        isStartLine = in.readByte() != 0;
        isDrawn = in.readByte() != 0;
    }

    public static final Creator<TwoPointLine> CREATOR = new Creator<TwoPointLine>() {
        @Override
        public TwoPointLine createFromParcel(Parcel in) {
            return new TwoPointLine(in);
        }

        @Override
        public TwoPointLine[] newArray(int size) {
            return new TwoPointLine[size];
        }
    };

    public boolean isStartLine() {
        return isStartLine;
    }

    public void setStartLine(boolean startLine) {
        isStartLine = startLine;
    }

    public List<LatLng> getLatLngs() {
        return latLngs;
    }

    public void setLatLngs(List<LatLng> latLngs) {
        this.latLngs = latLngs;
    }

    public boolean isDrawn() {
        return isDrawn;
    }

    public void setDrawn(boolean drawn) {
        isDrawn = drawn;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(latLngs);
        dest.writeByte((byte) (isStartLine ? 1 : 0));
        dest.writeByte((byte) (isDrawn ? 1 : 0));
    }
}
